
# 系统要求 win chrome >= 60

# 配置
from selenium import webdriver
from selenium.webdriver.firefox.options import Options

def handless_brower():
    chrome_options = Options()
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--disable-gpu')
    path = r'C:\Program Files\Mozilla Firefox\firefox.exe'
    chrome_options.binary_location = path
    browser = webdriver.Firefox(options=chrome_options)
    return browser

if __name__ == '__main__':
    browser = handless_brower()
    url = 'https://www.baidu.com'
    browser.get(url)
    # 快照
    browser.save_screenshot('../download/baiduHandless1.png')
    browser.quit()







# 无界面浏览器   phantomjs  了解
# 学习链接：https://www.cnblogs.com/ypppt/p/13323374.html
# https://selenium-python-zh.readthedocs.io/en/latest/
# https://phantomjs.org/download.html

# import time
# from selenium import webdriver
# path = './phantomjs-2.1.1-windows/bin/phantomjs.exe'
# browser = webdriver.PhantomJS(path)
# # AttributeError: module 'selenium.webdriver' has no attribute 'PhantomJS'
# url = 'https://www.baidu.com'
# browser.get(url)
# # 快照
# browser.save_screenshot('baidu.png')
# time.sleep(3)
# input_text = browser.find_element_by_id('kw')
# input_text.send_keys('../download/pyhon大数据')
# time.sleep(3)
# # 快照
# browser.save_screenshot('../download/pyhon大数据.png')
# time.sleep(3)
# browser.quit()





